home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c
- Subject: Re: How do you pass along a variable argument list?
- Date: Fri, 12 Jan 1996 03:54:38 GMT
- Organization: Netcom
- Message-ID: <30f5cfa3.8792640@nntp.ix.netcom.com>
- References: <4d1i8v$k8h@news.mcl.bdm.com> <4d30nv$k8r@tahko.lpr.carel.fi> <TANMOY.96Jan11091945@qcd.lanl.gov>
- NNTP-Posting-Host: ix-dc7-22.ix.netcom.com
- X-NETCOM-Date: Thu Jan 11 7:54:37 PM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) wrote:
-
- |>--text follows this line--
- |>In article <4d30nv$k8r@tahko.lpr.carel.fi>
- aril@cmt.lpr.mail.carel.fi
- |>(Ari Lukumies) writes:
- |><snip>
- |> >Hi, there:
- |>
- |> >I am writing a wrapper around a routine which takes variable
- |>argument list only. I
- |> >want my wrapper has the similar prototype and can pass the
- |>variable arguments
- |> >directly to the routine(by the way, I cannot change the code of
- |>that routine).
- |>
- |> >I guess it is really hard to do it in ANSI, and I know how to do
- |>it in a stupid
- |> >way---but, is there any way around??
- |>
- |> >Thanks!!
- |>
- |> >Yibing Wu
- |> >ywu@plato.sky.bdm.com
- |>
- |> Actually, it's not so difficult. Here's an ANSI-compliant example
- that
- |> wraps the printf function:
- |>
- |>Huh?! The FAQ describes that it is impossible in ANSI C: and you
- claim
- |>it is not difficult?
- |>
- |> #include <stdio.h>
- |> #include <stdarg.h>
- |>
- |> void MyPrintf(char *fmt, ...)
- |> {
- |> va_list argp;
- |>
- |> va_start(argp, fmt);
- |> printf(fmt, argp);
- |>
- |>Did you try this? A conforming compiler is _required_ to diagnose
- this.
- |>
- |> va_end(argp);
- |> }
-
- I'm missing something here. Why is a conforming compiler required to
- diagnose this? As I read ISO 7.8, a conforming compiler could define
- va_list as
-
- typedef int va_list;
-
- in which case this code is legal.
-
- In fact, I can find no constraings or syntax requirements in 7.9.6.1
- or 7.9.6.3 that would require a diagnostic no matter what the type of
- va_list is.
-
-
- Michael M Rubenstein
-